console.log("13PointSimplifier");
let utils = data["utils"];
let RBushItem = data["RBushItem"];
let RBU = data["RBU"];
let RBush = data["RBush"];
let AreaForRender = data["AreaForRender"];
let quickselect = data["quickselect"];
let SphericalMercator = data["SphericalMercator"];
let PointItem = data["PointItem"];
let PointForRender = data["PointForRender"];
let BoundsItem = data["BoundsItem"];
let QuadTree = data["QuadTree"];
let Node = data["Node"];
let PointSimplifier = data["PointSimplifier"];
let BaseRender = data["BaseRender"];
let LeftNumFunnel = data["LeftNumFunnel"];

utils.extend(PointSimplifier.prototype, {
  _adjustRootBounds: function (bounds) {
    var width = bounds.width,
      height = bounds.height,
      aspectRatio = width / height,
      badAspectRatio = this._opts.badBoundsAspectRatio;
    if (badAspectRatio) {
      badAspectRatio > 1 && (badAspectRatio = 1 / badAspectRatio);
      if (aspectRatio > 1 / badAspectRatio) {
        var newHeight = Math.ceil(width * badAspectRatio);
        bounds.y -= Math.floor((newHeight - bounds.height) / 2);
        bounds.height = newHeight;
      } else if (aspectRatio < badAspectRatio / 1) {
        var newWidth = Math.ceil(height * badAspectRatio);
        bounds.x -= Math.floor((newWidth - bounds.width) / 2);
        bounds.width = newWidth;
      }
    }
    var x = bounds.x,
      y = bounds.y,
      w = bounds.width,
      h = bounds.height,
      r = x + w,
      b = y + h,
      factor = 256;
    bounds.x = Math.floor(x / factor) * factor;
    bounds.y = Math.floor(y / factor) * factor;
    bounds.width = Math.ceil(r / factor) * factor - bounds.x;
    bounds.height = Math.ceil(b / factor) * factor - bounds.y;
    return bounds;
  },
  _buildQuadTree: function () {
    if (this._quadTree) {
      this._quadTree.clear();
      this._quadTree = null;
    }
    var bounds = this._data.bounds,
      opts = this._opts,
      items = this._data.list,
      quadBounds = this._adjustRootBounds(bounds);
    QuadTree.setMaxChildrenAndDepth(opts.maxChi, opts.maxDepth);
    var quadTree = new QuadTree(quadBounds, true, opts.maxDepth, opts.maxChi),
      root = quadTree.root,
      len = items.length;
    for (var i = 0; i < len; i++) root.insert(items[i]);
    this._quadTree = quadTree;
  },
  setData: function (data) {
    data || (data = []);
    this._buildData(data);
  },
  getMaxZoom: function () {
    return this._opts.zooms[1];
  },
  getOption: function (k) {
    return this._opts[k];
  },
  getAvoidPoints: function (min_lng, min_lat, max_lng, max_lat, curZoom, width, height) {
    console.log("getAvoidPoints");
    var avoidPoints = [];
    this.renderEngine.refreshViewState(min_lng, min_lat, max_lng, max_lat, curZoom, width, height);
    this.renderEngine.render();
    avoidPoints = this.renderEngine.curleftPoints;
    return avoidPoints;
  }
});

return {
  "utils": utils,
  "RBushItem": RBushItem,
  "RBU": RBU,
  "RBush": RBush,
  "AreaForRender": AreaForRender,
  "LeftNumFunnel": LeftNumFunnel,
  "quickselect": quickselect,
  "SphericalMercator": SphericalMercator,
  "PointItem": PointItem,
  "PointForRender": PointForRender,
  "BoundsItem": BoundsItem,
  "QuadTree": QuadTree,
  "Node": Node,
  "PointSimplifier": PointSimplifier,
  "BaseRender": BaseRender
}